package com.example.service;
import com.example.entity.FlTrainingTask;
import com.example.mapper.FLTrainingTaskMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
/**
 * ClassName: FLTrainingTaskService
 * Package: com.example.service
 * Description:
 *
 * @Author achb
 * @Create 2025/3/30 11:41
 * @Version 1.0
 */
@Service
public class FLTrainingTaskService {

    @Resource
    private FLTrainingTaskMapper flTrainingTaskMapper;

    /*新增*/
    public void add(FlTrainingTask flTrainingTask) {
        flTrainingTaskMapper.insert(flTrainingTask);
    }

    /*删除*/
    public void deleteByID(String taskId) {
        flTrainingTaskMapper.deleteById(taskId);
    }

    /*修改*/
    public void update(FlTrainingTask flTrainingTask) {
        flTrainingTaskMapper.updateById(flTrainingTask);
    }

    /*查询*/
    public FlTrainingTask getByID(String taskId) {
        return flTrainingTaskMapper.selectById(taskId);
    }

    /*查询所有*/
    public List<FlTrainingTask> getAll(FlTrainingTask flTrainingTask) {
        return flTrainingTaskMapper.selectAll(flTrainingTask);
    }

    /*分页查询*/
    public PageInfo<FlTrainingTask> selectPage(FlTrainingTask flTrainingTask, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<FlTrainingTask> list = flTrainingTaskMapper.selectAll(flTrainingTask);
        return PageInfo.of(list);
    }
}
